# @Time    : 2018/6/6 10:56
# @Author  : Jame
from interface import consumer_interface
from bin import Ftp_Client,Ftp_Server
from conf import setting


def login():
    print('login')
    while True:
        name = input('请输入用户名 <q 退出>:').strip()
        password = input('请输入密码 <q 退出>:').strip()
        if name=='q' or password=='q':break
        flag,msg=consumer_interface.consumer_login_interface(name,password)
        if flag:
            print("...........ftp server通信中..............................................................")
            ftp_client=Ftp_Client.FtpClient((setting.Server_Host,setting.Server_Port),flag.name)
            ftp_client.run()
        else:
            print(msg)


def register():
    print('注册>>>')
    while True:
        name = input('请输入注册用户名 <q 退出>:').strip()
        password = input('请输入注册密码 <q 退出>:').strip()
        conf_password = input('请再次输入注册密码 <q 退出>:').strip()
        if name == 'q' or password=='q' or conf_password=='q': break

        if password == conf_password:
            flag,msg = consumer_interface.consumer_register_interface(name,password)
            if flag:
                print(msg)
                break
            else:
                print(msg)
        else:
            print('两次密码不一致，请重新输入.')



def loginout():
    print('loginout')
    exit()
